package com.fqgj.sentry.controller.mc;

import com.fqgj.sentry.biz.mc.LoginBusiness;
import com.fqgj.sentry.common.annotations.ParamsValidate;
import com.fqgj.sentry.common.cache.RequestLocalInfo;
import com.fqgj.sentry.common.response.ApiOutput;
import com.fqgj.sentry.controller.mc.request.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by ykpbean kangping.ying@yuntu-inc.com
 *
 * @description
 * @create 2017-07-18 下午4:27
 */

@RestController
@RequestMapping("/admin")
public class LoginController {
    @Autowired
    private LoginBusiness loginBusiness;


    @ParamsValidate
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public ApiOutput login(@RequestBody LoginVo loginVo) {
        String token = loginBusiness.Login(loginVo.getAccount(), loginVo.getPassword());
        return new ApiOutput<>("token", token);
    }

    @RequestMapping(value = "/login/out", method = RequestMethod.POST)
    public ApiOutput loginOut() {
        loginBusiness.LoginOut(RequestLocalInfo.getCurrentUserId());
        return new ApiOutput<>();
    }
}
